home *** CD-ROM | disk | FTP | other *** search
- /* VERSION 0000 (DATE: 21.II.85) (TIME: 2:24 pm) */
- /*
- e (qed) screen editor
-
- (C) G. Nigel Gilbert, MICROLOGY, 1981
-
- August-December 1981
-
- Modified: Aug-Dec 1984: BDS-C 'e'(vers 4.6a) to 'qe' (J.W. Haefner)
- March 1985: BDS-C 'qe' to DeSmet-C 'qed' (J.W. Haefner)
-
- FILE: qedtv925
-
- FUNCTIONS: terminal,gotoxy,deleteline,linedelete,delpage,
- insertline,begdim,enddim,keytranslate,displayhelp
-
- PURPOSE: terminal dependent screen control functions
-
- NOTE this file is specific to the TeleVideo range of terminals.
- It may be used as a model for others
- */
-
- #include "qed.h"
-
- /* control key codes, here for convenience in defining terminal sequences*/
-
- #define CTRLA 0x01 /* SOH */
- #define CTRLB 0x02 /* STX */
- #define CTRLC 0x03 /* ETX */
- #define CTRLD 0x04 /* EOT */
- #define CTRLE 0x05 /* ENQ */
- #define CTRLF 0x06 /* ACK */
- #define CTRLG 0x07 /* BEL */
- #define CTRLH 0x08 /* BS */
- #define CTRLI 0x09 /* HT */
- #define CTRLJ 0x0a /* LF */
- #define CTRLK 0x0b /* VT */
- #define CTRLL 0x0c /* FF */
- #define CTRLM 0x0d /* CR */
- #define CTRLN 0x0e /* SO */
- #define CTRLO 0x0f /* SI */
- #define CTRLP 0x10 /* DLE */
- #define CTRLQ 0x11 /* DC1 */
- #define CTRLR 0x12 /* DC2 */
- #define CTRLS 0x13 /* DC3 */
- #define CTRLT 0x14 /* DC4 */
- #define CTRLU 0x15 /* NAK */
- #define CTRLV 0x16 /* SYN */
- #define CTRLW 0x17 /* ETB */
- #define CTRLX 0x18 /* CAN */
- #define CTRLY 0x19 /* EM */
- #define CTRLZ 0x1a /* SUB */
- #define SOH 0x01
- #define STX 0x02
- #define ETX 0x03
- #define EOT 0x04
- #define ENQ 0x05
- #define ACK 0x06
- #define BEL 0x07
- #define BS 0x08
- #define HT 0x09
- #define LF 0x0a
- #define VT 0x0b
- #define FF 0x0c
- #define RETURN 0x0d
- #define SO 0x0e
- #define SI 0x0f
- #define DLE 0x10
- #define DC1 0x11
- #define DC2 0x12
- #define DC3 0x13
- #define DC4 0x14
- #define NAK 0x15
- #define SYN 0x16
- #define ETB 0x17
- #define CAN 0x18
- #define EM 0x19
- #define SUB 0x1a
- #define ESC 0x1b
- #define FS 0x1c
- #define GS 0x1d
- #define RS 0x1e
- #define US 0x1f
- #define DEL 0x7f
-
- /*-------------------------OUTPUT TO SCREEN---------------------------*/
-
-
-
- /* screen control characters for TVI912C, ADM31 */
- #define BEGINDIM ')'
- #define ENDDIM '('
- #define CRSADDR '='
- #define INSLINE 'E'
- #define DELLINE 'T' /*delete to spaces*/
- #define LINDEL 'R' /*delete and close up*/
- #define PAGEDEL 'Y'
-
- terminal() /*display name of terminal*/
- {
- putstr("|for IBM PC (WordStar)");
- }
-
- terminit() /* init pc video characteristics */
- {
- scr_mode=2;
- scr_setup();
- }
-
- gotoxy(x,y) /*move cursor to column x, line y {top left is (0,0) */
- int x,y;
- {
- /*
- putch(ESC);
- putch(CRSADDR);
- putch(y+32);
- putch(x+32);
- */
- scr_rowcol(y,x);
- }
-
- deleteline(x,y) /*clear to spaces all characters on line y from column x
- to the right edge of the screen, inclusive.
- Leave cursor on left most blank */
- int x, y;
- {
- /*
- gotoxy(x,y);
- putch(ESC);
- putch(DELLINE);
- gotoxy(x,y);
- */
- scr_rowcol(y,x);
- scr_clrl();
- }
-
- linedelete(y) /*delete the line y. All following lines move up one.
- Leave cursor at start of line y */
- int y;
- {
- /*
- gotoxy(0,y);
- putch(ESC);
- putch(LINDEL);
- */
- scr_rowcol(y,0);
- scr_clrl();
- if (y<SHEIGHT) scr_scrup(1,y,0,SHEIGHT,SWIDTH);
- }
-
- delpage(y) /*clear to spaces line y and all following lines. Leave
- cursor at the start of line y */
- int y;
- {
- /*
- gotoxy(0,y);
- putch(ESC);
- putch(PAGEDEL);
- */
- scr_rowcol(y,0);
- scr_cls();
- }
-
- insertline() /*move all lines below line on which cursor is, down one,
- losing last line. New cursor line is blank, with
- cursor at start of line */
- {
- /*
- putch(ESC);
- putch(INSLINE);
- */
- int row;
- _rax=(3<<8);
- _rbx=0;
- _doint(0x10);
- row=_rdx>>8;
- if (row<SHEIGHT) scr_scrdn(1,row,0,SHEIGHT,SWIDTH);
- scr_rowcol(row,0);
- scr_clrl();
- }
-
- begdim() /*display all subsequent characters at half intensity*/
- {
- #if NOTIBMPC
- putch(ESC);
- putch(BEGINDIM);
- #else
- if (!isdim) isdim=YES;
- #endif
- }
-
- enddim() /* display all subsequent characters at full intensity */
- {
- #if NOTIBMPC
- putch(ESC);
- putch(ENDDIM);
- #else
- if (isdim) isdim=NO;
- #endif
- }
-
-
- /*----------------------INPUT FROM KEYBOARD-----------------------------*/
-
-
- keytranslate() /*defines the terminal key codes which perform
- the editor commands */
- {
- /* each tran[xxxx]= should be set to the code emitted by the terminal
- key which will perform the indicated action. The recommended (control)
- key assignments are shown in round brackets.
- Some terminals precede their codes by a lead-in character
- (eg the Hazeltine uses the tilde). This char should be assigned to
- tran[LEADIN]. If there is no lead-in character, set tran[LEADIN] to zero.
- 'e' will ignore the leadin character if tran[LEADIN] is non-zero,
- but will set the parity bit on the next character. All other chars from the
- keyboard will already have any parity bits removed as they are read in. Thus
- codes with lead-ins should be entered in the table below as code+0x80, or
- more clearly, as code+PARBIT.
- For example, suppose that one is coding the Hazeltine 1420, which
- generates a tilde,^L (0x0d) sequence when the cursor up key is pressd. To
- recognise this sequence, set tran[LEADIN] to tilde (0x7e) and set
- tran[UPKEY] to 0x0d+PARBIT.
- */
-
- tran[LEADIN]=0; /*lead-in character, 0 if not used*/
- tran[DOWNKEY]= CTRLX; /*cursor down */
- tran[UPKEY]= CTRLE; /*cursor up*/
- tran[LEFTKEY]= CTRLS; /*cursor left*/
- tran[RIGHTKEY]= CTRLD; /*cursor right*/
- tran[RIGHTWKEY]= CTRLF; /*cursor right one word (F) */
- tran[LEFTWKEY]= CTRLA; /*cursor left one word (A) */
- tran[EOLKEY]= CTRLP; /*cursor to end of line (P) */
- tran[BOLKEY]= CTRLO; /*cursor to beginning of line (P) */
- tran[UPPAGE]= CTRLR; /*scroll up a page (R) */
- tran[DOWNPAGE]= CTRLC; /*scroll down a page (C) */
- tran[BOFKEY]= CTRLU; /*cursor to beginning of file (U) */
- tran[HOMEKEY]= CTRLB; /*cursor to end of file (B) */
- tran[DELLEFT]= 0x7f; /*delete char to left of cursor (DEL) */
- tran[DELRIGHT]= CTRLG; /*delete char under cursor (G) */
- tran[DELLNKEY]= 0x1C; /*delete cursor line (^\) */
- tran[DELWDKEY]= CTRLT; /*delete word to right of cursor (T) */
- tran[JUMPKEY]= CTRLJ; /*jump to (J) */
- tran[CRSTILL]= CTRLN; /*insert newline after cursor (N) */
- tran[QWIKKEY]= CTRLQ; /*quit (Q) */
- tran[SCRLUPKEY]= CTRLW; /*scroll up thru text (W) */
- tran[TOPSCRKEY]= CTRLY; /*top of screen (Y) */
- tran[BOTSCRKEY]= CTRLV; /*bottom of screen (V) */
- tran[BLOCKKEY]= CTRLK; /*block operations (K) */
- tran[SCRLDNKEY]= CTRLZ; /*scroll down thru text (Z) */
- tran[REPKEY]= CTRLL; /*repeat last find/alter (L) */
- tran[UNDELINE]= 0x1e; /*restore deleted line (^^) */
- /*tran[HELPKEY]= 0x1e;*/ /*display help menu (^^) */
- tran[OOPSKEY]= 0x1f; /*restore unedited line (^_) */
- tran[TAB]= CTRLI; /*tab (I) */
- tran[RETRIEVE]= CTRLL; /*retrieve (L)*/
- tran[CR]= 0x0d; /*return*/
- tran[ESCKEY]=0x1b; /*escape, the magic key (ESC)*/
- }
-
- /*-------------------------------HELP MENU-------------------------------*/
-
-
- displayhelp() /*display the help menu. There must be (helplines-1)
- lines of menu here (see terminal function,above) */
- /* old help
- {
- putstr("CURSOR: ^B|=beginning of line| ^S|=left word| ^D|=right word| ^E|=end of line|\n");
- putstr("MOVE: ^W|=up a screen| ^Z|=down a screen| ^U|=top,| HOME|=bottom of file|\n");
- putstr("FIND: ^F|=find| ^R|=repeat last find/alter| ^A|=alter|\n");
- putstr("DELETE: DEL|=char left| ^G|=char right| ^T|=word| ^Y|=line| ^\\|=oops\n");
- putstr(" ^ ^Q|=quit| ^P|=read file| ^O|=write,print,shift,move,copy,or delete blOck\n");
- putstr(" <- -> ^X|=jump to line| ^N|=iNsert a new line |^C|=context |^V|=view menu off/on|\n");
- putstr("---v------------------------------------------------------------------------");
- }
- */
- {
- putstr("LEFT:| chr=|^S,^H| word=|^A| line=|^O RIGHT:| chr=|^D| word=|^F| line=|^P\n");
- putstr("UP:| scroll=|^W| line=|^E| page=|^R TOP:| scrn=|^Y| file=|^U\n");
- putstr("DOWN:| scroll=|^Z| line=|^X| page=|^C BOT:| scrn=|^V| file=|^B\n");
- putstr("DELETE:| chr-rt=|^G| chr-lf=|DEL| word=|^T| line=|^\\| EOL=|^QY RESTORE: ^_ ^^\n");
- putstr("SEARCH:| find=|^QF| replace=|^QA| repeat=|^L INSERT:| line=|^N JUMP: ^J| (repeat=|^KJ|)|\n");
- putstr("BLOCK:| quit=|^KQ| save=|^KX| read=|^KR| moves=|^KB STATUS:^QK HELP:^QO REFORM:^QP\n");
- putstr("------------------------------------------------------------------------------\n");
- }
- /*---------------------------------END---------------------------------------*/